package com.nineclock.attendance.controller;

import com.nineclock.attendance.dto.AttendGroupDTO;
import com.nineclock.attendance.service.AttendGroupService;
import com.nineclock.common.entity.PageResult;
import com.nineclock.common.entity.Result;
import com.nineclock.system.SysCompanyContactConfigController.AttendGroupControllerApi;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping
public class AttendGroupController implements AttendGroupControllerApi {
    /**
     * 分页查询考勤列表
     */
    @Autowired
    private AttendGroupService attendGroupService;

    @GetMapping("/attendGroup")
    @Override
    public Result<PageResult<AttendGroupDTO>> queryAttendGroupPage(
            @RequestParam(value = "page", required = false, defaultValue = "1") Integer page,
            @RequestParam(value = "pageSize", required = false, defaultValue = "10") Integer pageSize) {
        PageResult<AttendGroupDTO> pageResult = attendGroupService.queryAttendGroupPage(page, pageSize);

        return Result.success(pageResult);
    }

    /***
     *考勤:添加 考勤
     *
     */
    @PostMapping("/attendGroup")
    @Override
    public Result addAttendGroup(@RequestBody AttendGroupDTO attendGroupDTO) {
        attendGroupService.addAttendGroup(attendGroupDTO);
        return Result.success();
    }

    /**
     * 考勤组获取当前登入用户的考勤组
     * */
    @Override
    @GetMapping("/getAttendGroupByUserId")
    public Result<AttendGroupDTO> getAttendGroupByUserId() {
        AttendGroupDTO attendGroupDTO=attendGroupService.getAttendGroupByUserId();
        return Result.success(attendGroupDTO);
    }

}
